package com.rongji.dfish.framework.plugin.work.view;

import java.util.ArrayList;
import java.util.List;

import javax.servlet.http.HttpServletRequest;

import com.rongji.dfish.base.Page;
import com.rongji.dfish.base.Utils;
import com.rongji.dfish.ui.Widget;
import com.rongji.dfish.ui.command.AjaxCommand;
import com.rongji.dfish.ui.command.AlertCommand;
import com.rongji.dfish.ui.command.DialogCommand;
import com.rongji.dfish.ui.command.LoadingCommand;
import com.rongji.dfish.ui.command.SubmitCommand;
import com.rongji.dfish.ui.helper.FormPanel;
import com.rongji.dfish.ui.helper.GridLayoutFormPanel;
import com.rongji.dfish.ui.helper.GridPanel;
import com.rongji.dfish.ui.layout.ButtonBar;
import com.rongji.dfish.ui.layout.HorizontalLayout;
import com.rongji.dfish.ui.layout.VerticalLayout;
import com.rongji.dfish.ui.layout.View;
import com.rongji.dfish.ui.widget.Button;
import com.rongji.dfish.ui.widget.DialogTemplate;
import com.rongji.dfish.ui.widget.Html;
import com.rongji.dfish.ui.widget.PageBar;
import com.rongji.dfish.ui.widget.Split;
import com.rongji.dfish.ui.widget.TemplateTitle;
import com.rongji.dfish.ui.widget.TemplateView;
import com.rongji.dfish.ui.widget.TreePanel;

public class ViewTemplate {

	public static void fillPagePanel(PageBar pageBar, Page page) {
		if (pageBar == null || page == null) {
			return;
		}
		if (page.getCurrentPage() < 1) {
			page.setCurrentPage(1);
		}
		if (page.getPageSize() < 1) {
			page.setPageSize(15);
		}
		pageBar.setCurrentpage(page.getCurrentPage());
	//	pageBar.setMaxPage(page.getPageCount());
		pageBar.setSumpage(page.getRowCount());
	/*	int currentRecords = page.getCurrentPage() * page.getPageSize();
		if (currentRecords > page.getRowCount()) {
			currentRecords = page.getRowCount();
		}
		pageBar.setCurrentRecords(currentRecords);*/
	}

	public static void fillPagePanel1(HorizontalLayout hp, Page page, List<Object[]> data,
			String clkCmd) {
		//hp.setDirection("h");
		Html htmlPanel = new Html("", "页码：" + page.getCurrentPage()
				+ "/" + page.getPageCount() + " 记录：" + data.size() + "/"
				+ page.getRowCount() + "");
		htmlPanel.setStyle("margin:8px 15px 0 10px;");
		PageBar pageBar = getPageBar(page, clkCmd);
		// pagePanel.setShowInfo(true);
		pageBar.setCurrentpage(page.getCurrentPage());
		//pageBar.setCurrentRecords(data == null ? 0 : data.size());
		//pageBar.setMaxPage(page.getPageCount());
		pageBar.setSumpage(page.getRowCount());
		pageBar.setStyle("margin:10px 15px 0 10px;");
		pageBar.setOn(pageBar.EVENT_CLICK,clkCmd);
		pageBar.setAlign(PageBar.ALIGN_LEFT);

		hp.add(htmlPanel,"-1").add(pageBar,"-1");
	}






	public static SubmitCommand getSubmitCommand(String id, String act,
			String formId, String btnId) {
		boolean hasBtnId = Utils.notEmpty(btnId);
		SubmitCommand submit = new SubmitCommand(id);
		submit.setSrc(act);
		submit.setRange(formId);
		submit.setLoading(new LoadingCommand().setCover(true));
		if (hasBtnId) {
			submit.setBeforesend("VM(this).button('" + btnId
					+ "').setLoading(true);");
			submit.setError("VM(this).button('" + btnId
					+ "').setLoading(false);");
		}
		return submit;
	}

	public static AjaxCommand getAjaxCommand(String id, String act, String btnId) {
		AjaxCommand ajax = new AjaxCommand(id);
		ajax.setSrc(act);
		boolean hasBtnId = Utils.notEmpty(btnId);
		if (hasBtnId) {
			ajax.setBeforesend("VM(this).button('" + btnId
					+ "').setLoading(true);");
			ajax.setError("VM(this).button('" + btnId + "').setLoading(false);");
		}
		return ajax;
	}

	public static AlertCommand getInfoAlert(String alertMsg) {
		AlertCommand alert = new AlertCommand( alertMsg).setTimeout(5).setPosition(5);
		return alert;
	}

	public static AlertCommand getWarnAlert(String alertMsg) {
		AlertCommand alert = new AlertCommand( alertMsg).setTimeout(5);
		return alert;
	}



	public static View buildPopupFormView() {
		View view = new View();
		VerticalLayout popVP = new VerticalLayout(P_POP_ROOT);
		view.setNode(popVP);
		popVP.setCls("bg-white");

		FormPanel popForm = new FormPanel(P_POP_FORM);
		popVP.add(popForm);
		setPopupFormStyle(popForm);
		popForm.setScroll(true);
		ButtonBar popOper = new ButtonBar(P_POP_BTN);
		popOper.setPub(new Button(null).setCls("f-button").setStyle("min-width:64px;"));//.setWidth(64)
		popOper.setStyle("background-color:#eaeaea");
		popVP.add(popOper,"45");
		popOper.setAlign(ButtonBar.ALIGN_RIGHT);
		popOper.setStyle("padding:0 12px;background-color:#e5e6e8");

		return view;
	}

	public static void setPopupFormStyle(Widget<?> form) {
		if (form == null) {
			return;
		}
		// 设置弹出框表单块的样式
		form.setStyle("padding:20px 15px 0px 2px;");
		form.setCls("");
	}

	public static ButtonBar getButtonBar() {
		ButtonBar bbp = new ButtonBar(P_MAIN_RIGHT_TOP);
		bbp.setWmin(10);
		bbp.setPub(new Button(null).setCls("f-button").setStyle("min-width:64px;").setHeight(24));
		bbp.setAlign(ButtonBar.ALIGN_RIGHT);
		bbp.setCls("content-top-right");
		bbp.setHmin(2);
		return bbp;
	}

	public static Html getLeftTitleHtml(String funcName) {
		Html title = new Html(P_MAIN_LEFT_TOP, funcName);
		title.setCls("content-top-left");
		title.setHmin(2);
		title.setWmin(10);
		return title;
	}
	
	public static Html getMainTitleHtml(String funcName) {
		Html title = new Html(P_MAIN_TITLE, funcName);
		title.setAlign(Html.ALIGN_LEFT);
		title.setValign(Html.VALIGN_MIDDLE);
		title.setHmin(2);
		title.setCls("content-top-left");
		return title;
	}
	/**
	 * 弹窗根面板ID
	 */
	public static final String P_POP_ROOT = "pop_root";

	/**
	 * 弹窗表单面板ID
	 */
	public static final String P_POP_FORM = "f_form";

	/**
	 * 弹窗操作按钮面板ID
	 */
	public static final String P_POP_BTN = "f_btn";
	public static final String P_MAIN = "p_main";
	public static final String P_MAIN_TOP = "p_m_top";
	public static final String P_MAIN_LEFT = "p_m_left";
	public static final String P_MAIN_LEFT_TOP = "p_m_left_top";
	public static final String P_MAIN_LEFT_CONTENT = "p_m_left_content";
	
	public static final String P_MAIN_RIGHT = "p_m_right";
	public static final String P_MAIN_RIGHT_TOP = "p_m_right_top";
	public static final String P_MAIN_RIGHT_CONTENT = "p_m_right_content";
	
	
	public static final String P_MAIN_TITLE = "p_m_title";
	public static final String P_MAIN_BTN = "p_m_btn";
	public static final String P_MAIN_CENTER_BTN = "p_m_center_btn";
	public static final String P_MAIN_CONTENT = "p_m_content";
	public static final String P_MAIN_SEARCH = "p_m_search";
	public static final String P_MAIN_SEARCH_BUT = "p_m_search_but";
	public static final String P_MAIN_GRID = "p_m_grid";
	public static final String P_MAIN_PAGE = "p_m_page";
	public static final String P_MAIN_FORM = "p_m_form";
	public static final String P_MAIN_LEFT_PAGE = "p_m_left_page";
	
	public static final String TREE_SEARCH_FROM = "tree_search_from";
	public static final String TREE_SEARCH_BUT = "tree_search_but";
	
	public static final String CANDIDATE_MAIN = "candidate_main";
	public static final String CANDIDATE_PAGE = "candidate_page";
	public static final String CANDIDATE_GRID = "candidate_grid";
	
	
	//标题栏高度
	public static final String TITLE_HEIGHT = "43";
	
	public static View buildLeftAndRightView() {
		View view = new View();
		VerticalLayout root = new VerticalLayout(P_MAIN);
		root.setWmin(2);
		root.setHmin(2);
		view.setNode(root);
		root.setCls("content-root");
		
		HorizontalLayout top=new HorizontalLayout(null);
		root.add(top, String.valueOf(TITLE_HEIGHT));
		
		
		Html title = getLeftTitleHtml("这个面板一般用于菜单/导航，请替换它，他的ID为"+P_MAIN_LEFT_TOP);
		top.add(title,"25%");
		
		ButtonBar oper = getButtonBar();
		
		oper.setPub(new Button(null).setCls("f-button"));
		top.add(oper);
		
		HorizontalLayout main = new HorizontalLayout(P_MAIN);
		root.add(main);
		main.add(new TreePanel(P_MAIN_LEFT_CONTENT).setScroll(true),"25%");

		Split splitor = new Split();
		splitor.setId("splitor").setRange("10,50");
		main.add(splitor,"1");
		splitor.setCls("content-main-split");

		main.add(new GridLayoutFormPanel(P_MAIN_RIGHT_CONTENT));

		return view;
	}


	public static View buildMainView() {
		View view = new View();

		VerticalLayout shell = new VerticalLayout(P_MAIN);
		shell.setCls("content-root");
		shell.setWmin(2);
		shell.setHmin(2);
		view.setNode(shell);

		HorizontalLayout top = new HorizontalLayout(P_MAIN_TOP);
		shell.add(top,String.valueOf(TITLE_HEIGHT));

		Html title = getMainTitleHtml("请设置标题[面板ID:"
				+ P_MAIN_TITLE + "]");
		top.add(title,"25%");

		ButtonBar oper = ViewTemplate.getButtonBar();
		top.add(oper);
		top.add(new Html(null),"10");
		VerticalLayout content = new VerticalLayout(P_MAIN_CONTENT);
		shell.add(content);


		GridPanel grid = new GridPanel(P_MAIN_CONTENT);
		content.add(grid);
		grid.setCls("grid-odd content-main");
		grid.getHeadRow().setCls("handle_grid_head");
		//grid.getPub().setFocusType(GridPanelPubInfo.FOCUS_TYPE_ALWAYS);
		//grid.setHighlightMouseover(true);
		grid.setHmin(20);
		grid.setWmin(20);
		grid.getPub().setHeight(40);
		//grid.setHighlightStyle(HighlightStyle.always);
		grid.setNobr(true);
		
		HorizontalLayout pPage = getPagePlusPanel(null, null, null);
		content.add(pPage,"50");
		//pPage.setFace(PageBar.FACE_OFFICE);
		return view;
	}

	
	
	public static HorizontalLayout getSearchPanel() {
		HorizontalLayout searchHP = new HorizontalLayout("searchHP");
		searchHP.setStyle("margin:10px 9px 6px 9px;");
		searchHP.setCls("bd-title ");
		FormPanel searchForm = new FormPanel(TREE_SEARCH_FROM);
		searchForm.setScroll(false);
	//	searchForm.setStyle("padding:0px;margin-left:-17px;");
		searchHP.add(searchForm);
//		Combobox combobox = new Combobox("searchContent", "", "", "");
//		combobox.setTransparent(true);
//		combobox.setPlaceholder("搜索流程事项");
//		combobox.setHideLabel(true);
//		combobox.addValidate(new Validate().setMaxlength(100));
//		searchForm.add(combobox);

		ButtonBar searchBBP = new ButtonBar(TREE_SEARCH_BUT);
		searchBBP.setStyle("padding-top:3px;");
		searchHP.add(searchBBP,"30");
		searchBBP.setAlign(searchBBP.ALIGN_CENTER);
		Button toolsSearch = new Button("m/pub/img/task_search.png","");
		searchBBP.add(toolsSearch);
		return searchHP;
	}

	public static View buildIndexView() {
		View view = new View();
		VerticalLayout vp = null;
		String firstPanelHeight = "86";// 搜索栏默认高度
		String thireePanelHeight = "*";// 表格栏默认高度
		String fourPanelHeight = "40";// 翻页栏默认高度

		// 搜索栏
		HorizontalLayout p = new HorizontalLayout(P_MAIN_TOP);
		p.setCls("query-background bd-onlybottom bd-title");
		VerticalLayout conditionPanel = new VerticalLayout(P_MAIN_LEFT_TOP);
		conditionPanel.setStyle("padding-top:5px;padding-right:5px;");
		conditionPanel.setScroll(true);
		p.add(conditionPanel);
		GridLayoutFormPanel form = new GridLayoutFormPanel(P_MAIN_SEARCH);
		//form.setFace(GridPanelPubInfo.FACE_NONE);
		form.setCls("");
		//form.setHighlightMouseover(false);
		conditionPanel.add(form,"-1");

		// 按钮栏
		ButtonBar bbp = getMainSearchButtonBar();
		
		p.add(bbp,"120");
		
		// 列表显示
		GridPanel grid = new GridPanel(P_MAIN_CONTENT);
		grid.setNobr(true);
		grid.setCls("grid-odd content-main");
		//grid.setFace(GridPanelPubInfo.FACE_CELL);
		grid.getHeadRow().setCls("handle_grid_head");
		//grid.getPub().setFocusType(GridPanelPubInfo.FOCUS_TYPE_ALWAYS);
	//	grid.setHighlightMouseover(true);
		grid.setWmin(20);
		grid.setHmin(20);
		grid.getPub().setHeight(40);

		vp = new VerticalLayout(P_MAIN);
		vp.setHmin(2);
		vp.setWmin(2);
		vp.setCls("content-root");
		vp.add(p,firstPanelHeight);// 搜索栏
		vp.add(grid,thireePanelHeight);// 表格

		HorizontalLayout hp = new HorizontalLayout(ViewTemplate.P_MAIN_LEFT_PAGE);
		vp.add(hp,fourPanelHeight);
		view.add(vp);
		return view;
	}

	public static ButtonBar getMainSearchButtonBar() {
		ButtonBar bbp = new ButtonBar(P_MAIN_SEARCH_BUT);
		bbp.setAlign(ButtonBar.ALIGN_CENTER);
	//	bbp.setCellspacing(10);
	//	bbp.setDirectionVertical(true);
		return null;
	}
	public static View buildIndexHasBtnView() {
		View view = new View();
		VerticalLayout vp = null;// FIXME 搜索栏不能有175的高度
		String firstPanelHeight = "86";// 搜索栏默认高度
		String secondPanelHeight = "40";// 按钮栏默认高度
		String thireePanelHeight = "*";// 表格栏默认高度
		String fourPanelHeight = "40";// 翻页栏默认高度

		// 搜索栏
		HorizontalLayout p = new HorizontalLayout(P_MAIN_TOP);
		p.setCls("query-background bd-onlybottom bd-title");
		VerticalLayout conditionPanel = new VerticalLayout("condition");
		conditionPanel.setStyle("padding-top:5px;padding-right:5px;");
		conditionPanel.setScroll(true);
		p.add(conditionPanel);
		GridLayoutFormPanel form = new GridLayoutFormPanel(P_MAIN_SEARCH);
		//form.setFace(GridPanelPubInfo.FACE_NONE);
		form.setCls("");
		//form.setHighlightMouseover(false);
		conditionPanel.add(form);

		// 搜索按钮栏
		ButtonBar bbp = getMainSearchButtonBar();
		p.add(bbp,"120");
		//bbp.setCellspacing(10);
		//bbp.setDirectionVertical(true);

		// 列表显示
		GridPanel grid = new GridPanel(P_MAIN_CONTENT);
		grid.setNobr(true);
		grid.setCls("grid-odd content-main");
		//grid.setFace(GridPanelPubInfo.FACE_CELL);
		grid.getHeadRow().setCls("handle_grid_head");
		//grid.getPub().setFocusType(GridPanelPubInfo.FOCUS_TYPE_ALWAYS);
		//grid.setHighlightMouseover(true);
		grid.setWmin(20);
		grid.setHmin(20);
		grid.getPub().setHeight(40);

		vp = new VerticalLayout("f_root");
		//vp.setStyle("border:1px solid #B7CBE3;background-color:white;");//border-radius:5px;
		vp.setHmin(2);
		vp.setWmin(2);
		vp.setCls("content-root");
		vp.add(p,firstPanelHeight);// 搜索栏
		
		ButtonBar centerBtn = new ButtonBar(
					ViewTemplate.P_MAIN_CENTER_BTN);
		centerBtn.setStyle("padding-left:5px;background-color:#dfeafa");
		centerBtn.setAlign(centerBtn.ALIGN_LEFT);
		//centerBtn.setCellspacing(10);
		vp.add(centerBtn,secondPanelHeight);// 按钮
		
		vp.add(grid,thireePanelHeight);// 表格

		HorizontalLayout hp = new HorizontalLayout(ViewTemplate.P_MAIN_LEFT_PAGE);
		//hp.setDirection("h");
		vp.add(hp,fourPanelHeight);
		view.add(vp);
		return view;
	}

	public static HorizontalLayout getPagePlusPanel(Page page, List<Object[]> data,
			String clk) {
		if(page == null){
			page = new Page();
		}
		if(Utils.isEmpty(data)){
			data = new ArrayList<Object[]>();
		}
		HorizontalLayout hp = new HorizontalLayout(ViewTemplate.P_MAIN_LEFT_PAGE);
		Html htmlPanel = new Html("", "页码：" + page.getCurrentPage()
				+ "/" + page.getPageCount() + " 记录：" + data.size() + "/"
				+ page.getRowCount() + "");
		htmlPanel.setStyle("margin:8px 15px 0 10px;");
		hp.add(htmlPanel,"-1").add(
				getPageBar(page, clk)
						.setAlign(PageBar.ALIGN_LEFT));
		return hp;
	}

	public static PageBar getPageBar(Page page,
			String clk) {
		PageBar pageBar = new PageBar();
		pageBar.setId("f_page");
		pageBar.setOn(PageBar.EVENT_CLICK, clk);
		pageBar.setJump(false);
		pageBar.setCurrentpage(page.getCurrentPage());
		pageBar.setSumpage(page.getRowCount());
		pageBar.setStyle("margin:10px 15px 0 10px;");
		if (Utils.isEmpty(clk)) {
			pageBar.setOn(PageBar.EVENT_CLICK,"VM(this).cmd('turnPage',$0);");
		} else {
			pageBar.setOn(PageBar.EVENT_CLICK,clk);
		}
		return pageBar;
	}
	
	@SuppressWarnings("unchecked")
	public static DialogTemplate getPickerTemplate(HttpServletRequest request) {
		DialogTemplate dialog = new DialogTemplate();
		//dialog.setFace("f-picker");

		View CONTENT = new View("dlg-src");

		Html DLG_TITLE = new Html("dlg-tt", null);
		DLG_TITLE.setCls("m-tt");
		DLG_TITLE.setStyle("padding-left:6px;font-size:14px;");
		DLG_TITLE.setWmin(6);
		DLG_TITLE.setValign(Html.VALIGN_MIDDLE);

		Html DLG_CLOSE_BTN = new Html(
				"d-close",
				"<div class=\"d-close-16\" onmouseover=\"$.class_add(this, 'over')\" "
						+ "onmouseout=\"$.class_del(this, 'over')\" onclick=\"DFish.close(this);\" ></div>");
		DLG_CLOSE_BTN.setAlign(Html.ALIGN_CENTER);
		DLG_CLOSE_BTN.setValign(Html.VALIGN_MIDDLE);

		VerticalLayout stdRoot = new VerticalLayout(null);

		VerticalLayout stdTop = new VerticalLayout(null);
		stdTop.setCls("m-bg-top");

		HorizontalLayout titleHP = new HorizontalLayout(null);
		stdTop.add(titleHP);
		titleHP.setCls("bd-input bd-onlybottom");
		titleHP.setStyle("margin:0px 10px");
		titleHP.setHmin(1);
		titleHP.setWmin(20);

		titleHP.add(DLG_TITLE).add(DLG_CLOSE_BTN,"28");

		stdRoot.add(stdTop,"40").add(CONTENT);

		dialog.setNode(stdRoot);

		return dialog;
	}
	
	public static PageBar getTodoPageBar(String id,Page page, String clk) {
		PageBar pageBar = getPageBar(page, clk);
		pageBar.setId(id);
		return pageBar;
	}
	public static View buildCandidateView() {
		View view = new View();
		
		VerticalLayout root = new VerticalLayout(CANDIDATE_MAIN);
		root.setWmin(2);
		root.setHmin(2);
		root.setCls("candidate-root");
		view.add(root);

		GridPanel grid = new GridPanel(CANDIDATE_GRID);
		grid.setCls("lb");
		grid.setScroll(true);
		grid.setLimit(8);
		grid.setHasTableHead(false);
		
		
		root.add(grid).add(getCandidatePageBar(CANDIDATE_GRID),"30");
		return view;
	}

	public static PageBar getCandidatePageBar(String gridId){
		PageBar page = new PageBar(CANDIDATE_PAGE, PageBar.TYPE_MINI);
		page.setTarget(gridId).setAlign(PageBar.ALIGN_RIGHT);
		page.setBtncount(5);
		return page;
	}
	
	
	/**
	 * 对话框模板
	 * @return
	 */
	public static DialogTemplate getStdTemplate() {
		DialogTemplate std=new DialogTemplate().setId("std").setCls("dlg-std");
	
		VerticalLayout vp=new VerticalLayout(null);
		std.setNode(vp);
		HorizontalLayout head= new HorizontalLayout(null).setCls("dlg-std-head");
		vp.add(head,"40");
		head.add(new TemplateTitle(null).setCls("dlg-std-title").setWmin(10).setOn(Html.EVENT_DBLCLICK, "$.dialog(this).max(this)"),"*");
		head.add(new Html(null,"<i class=ico-dlg-max></i>").setCls("dlg-max").setAlign("center").setValign("middle").setOn(Html.EVENT_CLICK, "$.dialog(this).max(this)"),"40");
		head.add(new Html(null,"<i class=ico-dlg-close></i>").setCls("dlg-close").setAlign("center").setValign("middle").setOn(Html.EVENT_CLICK, 
				"if(!$.dialog(this).contentView.isModified()){$.dialog(this).close();}else{" +
				"$.dialog(this).contentView.cmd({type:'confirm',text:'您有内容尚未保存，确认关闭窗口吗？'," +
				"yes:function(){$.dialog(this).close();}});" +
				"}"),"40");
		
		TemplateView cont=new TemplateView(null);
		vp.add(cont,"*");
		return std;
	}
	
	/**
	 * 对话框模板,无需判断表单是否改变的模板
	 * @return
	 */
	public static DialogTemplate getStdxTemplate() {
		DialogTemplate std=new DialogTemplate().setId("stdx").setCls("dlg-std");
	
		VerticalLayout vp=new VerticalLayout(null);
		std.setNode(vp);
		HorizontalLayout head= new HorizontalLayout(null).setCls("dlg-std-head");
		vp.add(head,"40");
		head.add(new TemplateTitle(null).setCls("dlg-std-title").setWmin(10).setOn(Html.EVENT_DBLCLICK, "$.dialog(this).max(this)"),"*");
		head.add(new Html(null,"<i class=ico-dlg-max></i>").setCls("dlg-max").setAlign("center").setValign("middle").setOn(Html.EVENT_CLICK, "$.dialog(this).max(this)"),"40");
		head.add(new Html(null,"<i class=ico-dlg-close></i>").setCls("dlg-close").setAlign("center").setValign("middle").setOn(Html.EVENT_CLICK, 
				"$.dialog(this).close();"),"40");
		
		TemplateView cont=new TemplateView(null);
		vp.add(cont,"*");
		return std;
	}
	
	/**
	 * 对话框模板
	 * @return
	 */
	public static DialogTemplate getAlertTemplate() {
		DialogTemplate std=new DialogTemplate().setId("alert").setCls("dlg-std");
	
		VerticalLayout vp=new VerticalLayout(null);
		std.setNode(vp);
		HorizontalLayout head= new HorizontalLayout(null).setCls("dlg-std-head");
		vp.add(head,"40");
		head.add(new TemplateTitle(null).setCls("dlg-std-title").setWmin(10),"*");
		head.add(new Html(null,"<i class=ico-dlg-close></i>").setCls("dlg-close").setAlign("center").setValign("middle").setOn(Html.EVENT_CLICK, "$.dialog(this).close()"),"40");
		
		TemplateView cont=new TemplateView(null);
		vp.add(cont,"*");
		return std;
	}
	
	/**
	 * 对话框模板
	 * @return
	 */
	public static DialogTemplate getProngTemplate() {
		DialogTemplate std=new DialogTemplate().setId("prong").setCls("dlg-prong").setIndent(-10);
		VerticalLayout vp=new VerticalLayout(null);
		std.setNode(vp);
		vp.setAftercontent("<div class=dlg-prong-arrow-out></div><div class=dlg-prong-arrow-in></div>");
		
		HorizontalLayout head= new HorizontalLayout(null).setCls("dlg-prong-head");
		vp.add(head,"36");
		head.add(new TemplateTitle(null).setCls("dlg-prong-title"),"*");
		head.add(new Html(null,"<i onclick=$.close(this) class='dlg-close'>&times;</i><i class=f-vi></i>")
				.setAlign(Html.ALIGN_CENTER)
				.setValign(Html.VALIGN_MIDDLE),
				"40");
		
		TemplateView cont=new TemplateView(null);
		vp.add(cont,"*");
		return std;
	}

	/**
	 * 弹出窗口命令,自动判断表单是否改变
	 * @return
	 */
	public static DialogCommand getStdDialogCommand(String id,
			String title, String width, String height,
			int pos, String src) {
		return getDialogCommand(id, "std", title, width, height, pos, src);
	}
	
	/**
	 * 弹出窗口命令,无需判断表单是否改变
	 * @return
	 */
	public static DialogCommand getStdxDialogCommand(String id,
			String title, String width, String height,
			int pos, String src) {
		return getDialogCommand(id, "stdx", title, width, height, pos, src);
	}
	
	/**
	 * 弹出窗口命令
	 * @return
	 */
	public static DialogCommand getAlertDialogCommand(String id,
			String title, String width, String height,
			int pos, String src) {
		return getDialogCommand(id, "alert", title, width, height, pos, src);
	}
	
	public static DialogCommand getProngDialogCommand(String id,
			String title, String width, String height,
			int pos, String src) {
		return getDialogCommand(id, "prong", title, width, height, pos, src);
	}
	
	
	private static DialogCommand getDialogCommand(String id,String template,
			String title, String width, String height,
			int pos, String src){
		DialogCommand dialogCommand = new DialogCommand(id,template,title,
				width,height,
				pos,src);
		return dialogCommand;
	}
}
